package jmu.edu.yjc.controller;

import jmu.edu.yjc.domain.ResponseResult;
import jmu.edu.yjc.service.ArticleService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Arrays;

/**
 * @author yjc
 * @date 2023/4/12 16:20
 */
@RestController
@RequestMapping("/article")
public class ArticleController {
    @Resource
    private ArticleService articleService;
    //获取公告
    @GetMapping("/announcement")
    public ResponseResult getAnnouncement(Integer pageNum, Integer pageSize, String title) {
        return articleService.getAnnouncement(pageNum, pageSize ,title) ;
    }
    @GetMapping("/announcementDetail/{id}")
    public ResponseResult getAnnouncementDetail(@PathVariable("id") Long id) {
        return articleService.getArticleAndUpdateViewCount(id);
    }
    @GetMapping("/dashboardHotArticle")
    public ResponseResult getHotArticle() {
        return articleService.getHotArticle();
    }
    @GetMapping("/getArticle/{id}")
    public ResponseResult getArticle(@PathVariable("id") Long id) {
        return articleService.getArticleAndUpdateViewCount(id);
    }
    @GetMapping("/recommendArticle")
    public ResponseResult getRecommendArticle() {
        return articleService.getRecommendArticle();
    }
    @GetMapping("/articleList")
    public ResponseResult getArticleList(Integer pageNum, Integer pageSize,Long categoryId , String searchName) {
        return articleService.articleList(pageNum, pageSize, categoryId, searchName);
    }
    @GetMapping("/getSearchArticle")
    public ResponseResult getSearchArticle(String search) {
        return articleService.getSearchArticle(search);
    }
}
